<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sugar</title>
</head>

<body>
  <script>

    const arr = [{ name: '刘备' }, { name: '关羽' }, { name: '张飞' }];

    // 查找数组项
    const res = arr.find(item => item.name === '刘备')
    // 查找数组索引
    const resIndex = arr.findIndex(item => item.name === '刘备')

    console.log(res);         // undefined 或 数组的某一项
    console.log(resIndex);    // -1 或 数组的索引

    // console.log(res.name);
    if (res) {
      console.log(res.name);
    }

  </script>
</body>

</html>